package com.company.java.basic.day05;

import java.util.Scanner;

public class Day05_FamilyAccount {
    public static void main(String[] args) {
        String[] shouZhi =new String[10];
        int[] jinE = new int[10];
        int[] yuE = new int[10];
        String[] shoMing =new String[10];
        int benJin =10000;
        while (true){
            System.out.print("--------------");
            System.out.print("家庭收支记账软件");
            System.out.println("--------------");
            System.out.println("\t\t1 收支明细");
            System.out.println("\t\t2 登记收入");
            System.out.println("\t\t3 登记支出");
            System.out.println("\t\t4 退 出");
            System.out.print("\t\t请选择(1-4):");
            Scanner input = new Scanner(System.in);
            int choose = input.nextInt();
            if (choose==1){
                System.out.print("--------------");
                System.out.print("当前收支明细记录");
                System.out.print("--------------");
                System.out.println();
                System.out.print("收支\t");
                System.out.print("收支金额\t");
                System.out.print("账户金额\t");
                System.out.println("说明");
                for (int i=0;i<shouZhi.length;i++){
                    if (shouZhi[i]!=null){
                        System.out.print(shouZhi[i]+"\t");
                        System.out.print(jinE[i]+"\t\t");
                        System.out.print(yuE[i]+"\t  ");
                        System.out.println(shoMing[i]);
                    }
                }
                System.out.print("--------------");
                System.out.print("--------------");
                System.out.println("--------------");
            }else if (choose==2){
                System.out.print("本次收入金额:");
                int shoRu = input.nextInt();
                System.out.print("本次收入说明:");
                String sShuoMing = input.next();
                if (shoRu!=0){
                    benJin += shoRu;
                    for (int i=0;i<shouZhi.length;i++){
                        if (shouZhi[i]==null){
                            shouZhi[i] = "收入";
                            jinE[i] = shoRu;
                            yuE[i] = benJin;
                            shoMing[i] = sShuoMing;
                            break;
                        }
                    }
                }
            }else if (choose==3){
                System.out.print("本次支出金额:");
                int zhiChu = input.nextInt();
                System.out.print("本次支出说明:");
                String zShuoMing = input.next();
                if (zhiChu!=0){
                    benJin -= zhiChu;
                    for (int i=0;i<shouZhi.length;i++){
                        if (shouZhi[i]==null){
                            shouZhi[i] = "支出";
                            jinE[i] = zhiChu;
                            yuE[i] = benJin;
                            shoMing[i] = zShuoMing;
                            break;
                        }
                    }
                }
            }else if (choose==4){
                break;
            }

        }
    }
}
